package cn.jetpiece.cloud.joss.api.object;

import cn.jetpiece.cloud.joss.api.object.model.params.GetObject;
import cn.jetpiece.cloud.joss.api.object.model.params.JossPostObject;
import cn.jetpiece.cloud.joss.api.object.model.params.JossPutObject;
import cn.jetpiece.cloud.joss.api.object.model.result.UploadObjectResult;
import cn.jetpiece.cloud.model.response.Result;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 对象接口
 *
 * @author XuJZ
 * @since 2020-09-05 15:41:52
 */
public interface JossObjectFeign {

    /**
     * 上传对象
     *
     * @param params 请求信息
     * @return 对象信息
     */
    @RequestMapping(name = "文件上传", path = JossObjectApi.API + "/{objectName}", method = RequestMethod.POST)
    Result<UploadObjectResult> postObject(@PathVariable("objectName") String path, @SpringQueryMap JossPostObject params, @RequestParam(value = "file", required = false) MultipartFile file);

    /**
     * 上传对象
     *
     * @param params 请求信息
     * @return 对象信息
     */
    @RequestMapping(name = "文件上传", path = JossObjectApi.API + "/{objectName}", method = RequestMethod.PUT)
    Result<UploadObjectResult> putObject(@PathVariable("objectName") String path, @SpringQueryMap JossPutObject params, @RequestParam(value = "file", required = false) MultipartFile file);

    /**
     * 上传对象
     * model:3
     * url填入Body
     *
     * @param params 请求信息
     * @return 对象信息
     */
    @RequestMapping(name = "文件上传", path = JossObjectApi.API + "/{objectName}", method = RequestMethod.PUT)
    Result<UploadObjectResult> putObject(@PathVariable("objectName") String path, @SpringQueryMap JossPutObject params, @RequestBody String url);

    /**
     * 获取对象
     *
     * @param key    bucket/objectName
     * @param params 请求信息
     */
    @RequestMapping(name = "获取对象", path = JossObjectApi.API + "/{key}", method = RequestMethod.GET)
    UploadObjectResult getObject(@PathVariable("key") String key, @SpringQueryMap GetObject params);

    /**
     * 删除对象
     *
     * @param key bucket/objectName
     */
    @RequestMapping(name = "删除对象", path = JossObjectApi.API + "/{key}", method = RequestMethod.DELETE)
    Result<String> deleteObject(@PathVariable("key") String key);
}
